# # 导包
# from flask import Flask
#
# # 实例初始化Flask类对象
# app = Flask(__name__)
#
# app.config.from_pyfile("config.py")
#
#
# @app.route("/home")
# def home():  # 视图函数，用来处理请求，做出响应
#     print("=====home视图函数=====")
#     return "首页"
#
#
# # 第一次请求
# @app.before_first_request
# def before_first_request():
#     print("=====before_first_request=====")
#
#
# # 每次请求前
# @app.before_request
# def before_request():
#     print("=====before_request=====")
#
#
# # 每次请求后
# @app.after_request
# def after_request(post):
#     print(post)
#     print("=====after_request=====")
#     return post
#
# # 每次请求后
# @app.teardown_request
# def teardown_request(e):
#     print("=====teardown_request=====")
#
# if __name__ == '__main__':
#     app.run()


from flask import Flask

app = Flask(__name__)

app.config.from_pyfile("config.py")

# 创建视图函数   接受请求 做出响应
@app.route("/home")
def home():
    print("=====home视图函数=====")
    return "首次创建钩子请求"

# 第一次请求前
@app.before_first_request
def before_first_request():
    print("=====before_first_request=====")

# 每次请求后
@app.before_request
def before_request():
    print("=====before_request=====")

# 每次请求后
@app.after_request
def after_request(name):
    print(name)
    print("=====after_request=====")
    return name


# 每次请求后
@app.teardown_request
def teardown_request(e):
    print("=====teardown_request=====")


if __name__ == '__main__':
    app.run()







